package sasku.client.core;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import sun.misc.BASE64Encoder;

public class Util {

	public static String toSha1(String value) {
		try {
			MessageDigest md = MessageDigest.getInstance("SHA");
			md.update(value.getBytes("UTF-8"));
			byte raw[] = md.digest();
			return (new BASE64Encoder()).encode(raw);
		} catch (NoSuchAlgorithmException e) {
			throw new RuntimeException(e);
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e);
		}
	}
}
